Repository navigation
Packages: Move data module to the package maintained by Lerna - #6828
Conversation
For me it's fine. I think it's not even used by default unless you explicitly import the persisting helper. |
Since this is the first packages that users So what I propose is to do something similar to React:
|
| @@ -1,9 +1,17 @@ | |||
| # Data | |||
| # @wordpress/date | |||
There was a problem hiding this comment.
Should be @wordpress/data
0f721cd to
04e52b0
Compare
True, however, I added a way to override the default persistence storage with 04e52b0 :) |
Sounds like a good idea. With the small exception, we should limit Eslint check to |
04e52b0 to
d458cb9
Compare
Done with 6c26c4b. There is one more thing which popped up after rebase. We need to move |
075da81 to
d1f6717
Compare
Introduced also |
|
@gziolo Do you think it's possible to extract the devtools package to its own PR, I feel it could make it way quicker than the data one? |
Sure thing - it is in its own commit - doing it now. |
|
@youknowriad - I opened #6914 with |
d1f6717 to
169ae93
Compare
|
|
| }, | ||
| }, | ||
| }, | ||
| ], |
There was a problem hiding this comment.
I believe we still need a similar config for babel to generate the Right JS (instead of using the global)
There was a problem hiding this comment.
Confirmed, I will look into it.
There was a problem hiding this comment.
It should be fixed with f7afc46.
169ae93 to
f7afc46
Compare
aduth
left a comment
There was a problem hiding this comment.
I'm fine with explicit createElement pragma. Would hope we'd apply it consistently eventually.
| const babelDefaultConfig = require( '@wordpress/babel-preset-default' ); | ||
| babelDefaultConfig.babelrc = false; | ||
| // TODO: It should become the default value when all modules are moved to packages. | ||
| babelDefaultConfig.plugins[ 1 ][ 1 ].pragma = 'createElement'; |
There was a problem hiding this comment.
- Must we mutate? Can we assign into a new object? Not sure what would break, but certainly seems prone to cause breakage as implemented.
- Similarly, the
[ 1 ][ 1 ]assumes a very specific order which, while we maintain and is unlikely to change anytime soon, is certainly incredibly fragile.
There was a problem hiding this comment.
I opted for a quick fix with the hope that it won't last for long. I guess it is going to be around for a couple of weeks at least so I'm happy to provide more solid processing of default Babel config.
| Install the module | ||
|
|
||
| ```bash | ||
| npm install @wordpress/data@next --save |
There was a problem hiding this comment.
You are right, we can publish alpha without using dev :)
| "url": "https://github.com/WordPress/gutenberg/issues" | ||
| }, | ||
| "main": "src/index.js", | ||
| "dependencies": { |
There was a problem hiding this comment.
Tests use deep-freeze and enzyme. Do we need to reflect that anywhere in this file as a dependency?
There was a problem hiding this comment.
Given that we are going to move those packages elsewhere one day, let's keep all dependencies listed. I will add them.
There was a problem hiding this comment.
I forgot that enzyme is already included in @wordpress/scripts by design.
There was a problem hiding this comment.
I think we should be explicit :) If we use enzyme directly here in our tests, it should be a direct dependency
| { | ||
| "name": "@wordpress/data", | ||
| "version": "0.0.1", | ||
| "description": "Data Redux module for WordPress", |
There was a problem hiding this comment.
The documentation clearly states:
The data module is built upon and shares many of the same core principles of Redux, but shouldn't be mistaken as merely Redux for WordPress
Is this not in contradiction?
| */ | ||
| import { get } from 'lodash'; | ||
|
|
||
| // Defaults to the local storage. |
There was a problem hiding this comment.
So we default to a broken (error-throwing) state for Node environments where this package is used?
It's probably a larger dependency than we'd want, but something like Store.js is a good abstraction for this sort of thing.
There was a problem hiding this comment.
Not really, you can make it work by using setter method introduced in this PR:
import store from 'store';
setPersistenceStorage( store );It isn't ideal, needs to be documented but should allow us to move forward. I will add the following example in the README file.
There was a problem hiding this comment.
Let's tackle it seperately as we don't have any docs for loadAndPersist anyways.
|
Let's get it in and see how it goes 🎉 |
Description
Related issues: #3955, #6594.
Similar: #6658, #6756, #6758.
After moving
dateandelement, this PR movesdatamodule topackagesfolder maintained byLerna.This is the first time where a package depends on another Gutenberg package (
element).Open question
datamodule useswindow.localStoragewhich won't work in non-browser environments. Are we fine with having it included in the initial release? Should we add guard which disable persistence when local storage is not provided?How has this been tested?
Manually:
node_modulesfolder.npm installnpm testnpm run devnpm run buildnpm run package-pluginTypes of changes
Refactoring.
Checklist: